<template>
  <div class="left">
    <el-row :gutter="12">
      <el-col :span="24">
        <el-card shadow="hover" style="border-radius: 10px">
          <div>
            <ul class="flex">
              <li @click="moveTo(1)"><img src="../assets/projectImg/推荐.png" height="20" width="20"/><a>社区动态</a></li>
              <li @click="moveTo(2)"><img src="../assets/projectImg/最新.png" height="20" width="20"/><a>我的动态</a></li>
              <li @click="moveTo(3)"><img src="../assets/projectImg/个人中心.png" height="20" width="20"/><a>我的聊天</a></li>
              <li @click="moveTo(4)"><img src="../assets/聊天.png" height="20" width="20"/><a>关注动态</a></li>
              <li v-if="isShow" @click="moveTo(5)"><img src="../assets/预测.png" height="20" width="20"/><a>糖尿病预测</a></li>
              <li v-if="isDoc" @click="moveTo(6)"><img src="../assets/team.png" height="20" width="20"/><a>我的群聊</a></li>
            </ul>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "Left",
  data() {
    return {
      isShow: false,
      isDoc: false
    }
  },
  created() {
    this.isUser().then(res => {
      if (res) {
        this.isShow = true
      }
    })
    this.isDoctor().then(res => {
      if (res) {
        this.isDoc = true
      }
    })
  },
  methods: {
    moveTo(data) {
      if (data == 1) {
        this.$router.push('/index');
      } else if (data == 2) {
        this.$router.push('/self');
      } else if (data == 3) {
        this.$router.push('/friend');
      } else if (data == 4) {
        this.$router.push('/followDynamic');
      } else if (data == 5) {
        this.$router.push('/diabetesPrediction');
      } else {
        this.$router.push('/team');
      }
    },
    isUser() {
      return new Promise(resolve => {
        this.$http.get("/user/isUserHimself").then(res => {
          resolve(res.data)
        })
      })
    },
    isDoctor() {
      return new Promise(resolve => {
        this.$http.get("/doctor/isDoctorHimself").then(res => {
          resolve(res.data)
        })
      })
    },
  }
}
</script>

<style scoped>
.left {
  width: 240px;
  float: left;
  position: fixed;
}

.flex {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

li {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  text-align: center;
  background-color: #eaeaea;
  margin-top: 20px;
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 5px;
  cursor: pointer;
}

a {
  cursor: pointer;
  /*width: 100%;*/
  height: 100%;
  display: block;
}
</style>